package liumengbaio.lolzhangyoubao.Activity.Activity;

import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.Toast;

import liumengbaio.lolzhangyoubao.Activity.View.TextViewCustomDialog;
import liumengbaio.lolzhangyoubao.R;

/**
 * Created by lanouhn on 16/9/10.
 */
public class SettingActivity extends AppCompatActivity implements View.OnClickListener {
    private Button head_left_title;
    private RelativeLayout relative_pwd_setting,msg_setting;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.setting_activity);
        initView();
        initData();
    }

    private void initData() {
        head_left_title.setOnClickListener(this);
        relative_pwd_setting.setOnClickListener(this);
    }

    private void initView() {
        head_left_title = (Button) findViewById(R.id.head_left_title);
        relative_pwd_setting = (RelativeLayout) findViewById(R.id.relative_pwd_setting);
        findViewById(R.id.msg_setting).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent msg_setting_intent=new Intent(SettingActivity.this,msgActivity.class);
                startActivity(msg_setting_intent);
            }
        });
        findViewById(R.id.acount_bind_setting).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent_acount_bind_setting=new Intent(SettingActivity.this,AcountActivity.class);
                startActivity(intent_acount_bind_setting);
            }
        });
        findViewById(R.id.del_catch).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                setGood_side();
            }
        });
        findViewById(R.id.info_push).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent_info_push=new Intent(SettingActivity.this,InfoPushActivity.class);
                startActivity(intent_info_push);
            }
        });
        findViewById(R.id.feed_back).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent_feed_back=new Intent(SettingActivity.this,FeedBackActivity.class);
                startActivity(intent_feed_back);
            }
        });
        findViewById(R.id.add_relative).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent_add_relative=new Intent(SettingActivity.this,AddFriendActivity.class);
                startActivity(intent_add_relative);
            }
        });
        findViewById(R.id.about_zhangyoubao).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent_about_zhangyoubao=new Intent(SettingActivity.this,AbouteActivity.class);
                startActivity(intent_about_zhangyoubao);
            }
        });
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.head_left_title:
                finish();
                break;
            case R.id.relative_pwd_setting:
                Intent intent_pwd_setting=new Intent(SettingActivity.this,PwdSetting.class);
                startActivity(intent_pwd_setting);
                break;
        }
    }
    private void setGood_side() {
        final TextViewCustomDialog.Builder builder_signal_good = new TextViewCustomDialog.Builder(this);
        builder_signal_good.setTitle("提示");
        builder_signal_good.setMessage("是否清理应用的缓存文件？("+(int)(300+Math.random()*500)+"KB)");
        builder_signal_good.setPositiveButton("取消", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();

            }
        });

        builder_signal_good.setNegativeButton("确认",
                new android.content.DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        Toast.makeText(SettingActivity.this, "删除成功", Toast.LENGTH_SHORT).show();
                    }
                });

        builder_signal_good.create().show();

    }
}
